package 打怪;

import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int T = in.nextInt();
        while (T-- > 0) {
            int h = in.nextInt();
            int a = in.nextInt();
            int H = in.nextInt();
            int A = in.nextInt();
            int res = 0;
            if (a >= H) {
                res = -1;
            } else {
                int n = H / a + (H % a == 0 ? 0 : 1);
                int m = A * (n - 1);
                res = h / m - (h % m == 0 ? 1 : 0);
            }
            System.out.println(res);
        }
    }
}
